package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.model.Goods;

import java.util.List;

@Mapper
@Component
public interface BarCodeMapper {
    @Select("select max(bar_code) from goods where bar_code regexp '^${barcode}'")
    String select_max_bar_code(@Param(value = "barcode") String barcode);

    @Select("select id,bar_code from goods where bar_code is null or bar_code = '' order by sort")
    List<Goods> select_bar_code();

    @Update("update goods set `bar_code` = #{barcode} where `id` = #{id}")
    void updatebarcode(@Param("barcode") String barcode,@Param("id") Integer id);

    @Select("select max(only_bar_code) from goods where only_bar_code regexp '^${barcode}'")
    String select_max_only_bar_code(@Param(value = "barcode") String barcode);

    @Select("select id,only_bar_code from goods where bar_code is null or only_bar_code = '' order by sort")
    List<Goods> select_only_bar_code();

    @Update("update goods set `only_bar_code` = #{barcode} where `id` = #{id}")
    void updateonlybarcode(@Param("barcode") String barcode,@Param("id") Integer id);
}
